<!DOCTYPE html>
<html>
<head>
  <script src="../../processing.js"></script>
<link rel="stylesheet" href="../style.css"/></head>
<body><h1><a href="http://ejohn.org/blog/processingjs/">Processing.js</a></h1>
<h2>SaveManyImages</h2>

<p>The saveFrame() function allows you to save images from
a program while it is running. This example saves the first
50 frames of a program. These images can be imported into
animation software or QuickTime and then saved as a movie.</p>

<p><a href="http://processing.org/learning/topics/savemanyimages.html"><b>Original Processing.org Example:</b> SaveManyImages</a><br>
<script type="application/processing">
float x = 33;
float numFrames = 50;

void setup() 
{
  size(200, 200);
  smooth();
  noStroke();
}

void draw() 
{
  background(0);
  x += random(-2, 2);
  ellipse(x, 100, 80, 80);
  if (frameCount <= numFrames) {
    saveFrame("circles-####.tif");
  }
}
</script><canvas width="200" height="200"></canvas></p>
<div style="height:0px;width:0px;overflow:hidden;"></div>

<pre><b>// All Examples Written by <a href="http://reas.com/">Casey Reas</a> and <a href="http://benfry.com/">Ben Fry</a>
// unless otherwise stated.</b>
float x = 33;
float numFrames = 50;

void setup() 
{
  size(200, 200);
  smooth();
  noStroke();
}

void draw() 
{
  background(0);
  x += random(-2, 2);
  ellipse(x, 100, 80, 80);
  if (frameCount &lt;= numFrames) {
    saveFrame("circles-####.tif");
  }
}</pre>
</body>
</html>
